package com.example.demo.dto;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import javax.validation.constraints.Pattern;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
@Schema(name = "LoginDTO", description = "用户登录数据传输对象")
public class LoginDTO {

    @NotBlank(message = "用户名不能为空")
    @Size(min = 4, max = 20, message = "用户名长度需为4-20位")
    @Schema(description = "用户名", example = "john_doe", minLength = 4, maxLength = 20)
    private String username;

    @NotBlank(message = "密码不能为空")
    @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d).{8,}$", message = "密码需包含字母和数字且至少8位")
    @Schema(description = "密码", example = "Password123", format = "password")
    private String password;

    // 无参构造函数
    public LoginDTO() {
    }

    // 全参构造函数
    public LoginDTO(String username, String password) {
        this.username = username;
        this.password = password;
    }
}